home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / MSG Demo 1.4.source Folder / Demo ƒ / Wipes reversed ƒ / Corner circle reversed.c < prev    next >
Text File  |  1994-04-15  |  3KB  |  92 lines

  1. /**********************************************************************\
  2.  
  3. File:        Corner circle reversed.c
  4.  
  5. Purpose:    Graphic effect from offscreen bitmap to main window (on
  6.             screen).  See comments below for more description.
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program in a file named "GNU General Public License".
  20. If not, write to the Free Software Foundation, 675 Mass Ave,
  21. Cambridge, MA 02139, USA.
  22.  
  23. \**********************************************************************/
  24.  
  25. #include "timing.h"
  26.  
  27. #define    gap            8        /* difference between one radius and the next */
  28. #define CorrectTime 2
  29.  
  30. pascal short CornerCircleReversed(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect);
  31.  
  32. /* Make progressively larger circle regions, centered at the top-left corner
  33.    of the screen, until you are covering the bottom-right of the screen.  Copy
  34.    regions that are the difference between the boundsRect and this circle, then
  35.    make the circle smaller.  Quickdraw takes care of all the excess space off
  36.    the screen that you include in the region. */
  37.    
  38. pascal short CornerCircleReversed(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect)
  39. {
  40.     Rect            theRect;
  41.     RgnHandle        curregion,lastregion,diffregion;
  42.     Point            zeroPoint;
  43.     int                StartRadius;
  44.     
  45.     zeroPoint.h=boundsRect.right;
  46.     zeroPoint.v=boundsRect.bottom;
  47.  
  48.     lastregion=NewRgn();
  49.     StartRadius=0;
  50.     do
  51.     {
  52.         StartRadius+=4*gap;
  53.         theRect.left=-StartRadius;     /* circumscribing rectangle for outer circle */
  54.         theRect.right=StartRadius;
  55.         theRect.top=-StartRadius;
  56.         theRect.bottom=StartRadius;
  57.         OffsetRect(&theRect, boundsRect.left, boundsRect.top);
  58.         SetEmptyRgn(lastregion);
  59.         OpenRgn();
  60.             FrameOval(&theRect);        /* first circle */
  61.         CloseRgn(lastregion);
  62.     }
  63.     while (!PtInRgn(zeroPoint, lastregion));
  64.     
  65.     curregion=NewRgn();
  66.     diffregion=NewRgn();
  67.  
  68.     while (theRect.right-theRect.left>0)
  69.     {
  70.         StartTiming();
  71.         theRect.left+=gap;
  72.         theRect.right-=gap;
  73.         theRect.top+=gap;
  74.         theRect.bottom-=gap;
  75.         SetEmptyRgn(curregion);
  76.         OpenRgn();
  77.             FrameOval(&theRect);   /* inner circle */
  78.         CloseRgn(curregion);
  79.         DiffRgn(lastregion,curregion,diffregion);   /* donut we need */
  80.         CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  81.                 &boundsRect, &boundsRect, 0, diffregion);
  82.         CopyRgn(curregion,lastregion);    /* outer circle = inner circle */
  83.         TimeCorrection(CorrectTime);
  84.     }
  85.     
  86.     DisposeRgn(curregion);
  87.     DisposeRgn(lastregion);
  88.     DisposeRgn(diffregion);
  89.     
  90.     return 0;
  91. }
  92.